package cn.xiaopengstack.domain.trade.rule.factory;

import cn.xiaopengstack.domain.trade.model.valobj.GroupBuyOrderListStatusEnum;
import cn.xiaopengstack.domain.trade.model.valobj.GroupBuyOrderStatusEnum;
import cn.xiaopengstack.domain.trade.model.valobj.RefundTypeEnumVO;
import cn.xiaopengstack.domain.trade.rule.refund.IRefundStrategy;
import cn.xiaopengstack.types.utils.SpringContextUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author jiangyangang
 */
@Component
@Slf4j
public class TradeRefundStrategyFactory {

    /**
     * 获取退款策略
     * @param groupBuyOrderStatusEnum
     * @param groupBuyOrderListStatusEnum
     * @return
     */
    public IRefundStrategy getStrategy(GroupBuyOrderStatusEnum groupBuyOrderStatusEnum, GroupBuyOrderListStatusEnum groupBuyOrderListStatusEnum){
        RefundTypeEnumVO type = RefundTypeEnumVO.getType(groupBuyOrderStatusEnum, groupBuyOrderListStatusEnum);
        return SpringContextUtil.getBean(type.getStrategy());
    }
}
